Re-Write Tutorial

Diferences

The Re-write function replaces the Redirect option found in the Web service site details in older versions.

The Web Service - Site - Redirect option in the Administration GUI allowed you to define redirect rules based on the URL and URI. The requests that came to the server based on some string criteria were redirected to other pages. This option has been renamed to Rewrite and currently supports the old functionality for backward compatibility and a new mod_rewrite regex replace mechanism.

Non-RegEx (old way) does always redirect and the user can see the change in browser address bar. RegEx way rewrites the URL internally so for the user the URL appears to be the one shown in address bar.

Alias option has been renamed to Directory Aliases and is strictly for virtual directories. You can have a relative alias (pointing to the current web site repository, /mail/ –> webmail/) or absolute pointing to any directory or disk on your computer – /data/ –> /www/mydata/. Subdirectories are also supported, there is a new no match strings function.

  • Rewrite without RegEx does the former redirect – thus Redirect can be achieved.
  • Rewrite with RegEx does rewrite and supports mod_rewrite options.

Aliases are only directory aliases and support absolute and relative paths.

Directory Aliases - Absolute Path

Let's start with a short tutorial of directory aliases. There will be more examples to show what is supported and what you can do with it.

No string match functions can be used in aliases. Only the first part of the source is matched with the URI and then the path is replaced accordingly. In Absolute Path Directory Aliases, Destination is an absolute path.

/data/ -> /www/mydata/

If we have a path /data/... on the server, it will be physically loaded from /www/mydata/.... (with Linux path of course).

On Windows you could write

/data/ -> c:\www\data\

If the user specifies /data/ in the URL it does not have to be in the actual web sites directory but it can be loaded externally from some other location (c:\www\data\). That is what directory aliases is all about.

Directory Aliases - Relative Path

Below is an example of a relative path directory alias. In most cases you would use Rewrite feature but it is possible to use an alias for a similar functionality. In Relative Path Directory Aliases, Destination is a relative path.

/mail/ -> webmail/

This makes sure that if somebody goes to http://server/mail/... it will redirect him to the IceWarp WebClientdirectory in the web site repository.

All files loaded through the URI /mail/... will be in fact read from /webmail/.

Notice the missing "/" at the beginning of the destination value. This is a mark of relative directory alias.